package com.qhg.saas_server.controller;

import com.qhg.saas_server.annotation.Mylog;
import com.qhg.saas_server.empty.Result;
import com.qhg.saas_server.pojo.Company;
import com.qhg.saas_server.service.impl.CompanyServiceImpl;
import com.qhg.saas_server.utils.TencentCOSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@CrossOrigin
@RestController
@RequestMapping("/Company")
public class CompanyController {

    @Autowired
    CompanyServiceImpl companyService;

    /*查询公司的相关信息*/
    @GetMapping("/SelectCompany")
    @Mylog(value = "查询公司的相关信息")
    public Result SelectCompany(Integer comId){
        Company company = companyService.SelectCompany(comId);
        return Result.success(company);
    }
    /*修改公司信息*/
    @PostMapping("/UpdateCompanyById")
    @Mylog(value = "修改公司信息")
    public Result UpdateCompanyById(@RequestBody Company company){
        companyService.UpdateCompanyById(company);
        return Result.buildSuccess();
    }
    @PostMapping("/insertCompany")
    @Mylog(value = "插入公司信息")
    public Result insertCompany(@RequestBody Company company){
        System.out.println(company);
        companyService.insertCompany(company);
        return Result.buildSuccess();
    }
    @PostMapping("/UploadJpg")
    public Result UploadJpg(MultipartFile file){
        String uploadfile = TencentCOSUtil.uploadfile(file);
        return Result.success(uploadfile);
    }


}
